package com.iking.housekeeping.service.changeService;

import com.iking.housekeeping.dao.changeservice.ChangeServiceMapper;
import com.iking.housekeeping.entity.elderly.Elderly;
import com.iking.housekeeping.httpbean.servicestaff.reqbean.HttpGiveElderly;
import com.iking.housekeeping.service.elderly.ElderlyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.iking.housekeeping.entity.changeservice.ChangeService;

import java.util.ArrayList;
import java.util.List;

@Service
public class ChangeServiceS {
    @Autowired
    private ChangeServiceMapper changeServiceMapper;

    /**
     * 老人管理
     */
    @Autowired
    private ElderlyService elderlyService;

    /**
     *
     * @Description: 查询所有要更改的服务
     * @author:cj
     * @return
     */
   public List<ChangeService> selectAllChange (ChangeService changeService){
       List<ChangeService> list =changeServiceMapper.selectAllChange(changeService);
       return list;
   }

    /**
     *
     * @Description: 根据id查询要更改的服务
     * @author:cj
     * @param id
     * @return
     */
    public ChangeService selectById(String id){
        ChangeService changeService = changeServiceMapper.selectByPrimaryKey(id);
        return  changeService;
    };

    /**
     *
     * @Description: 更改服务
     * @author:cj
     * @param record
     * @return
     */
    public int updateService(ChangeService record){
         changeServiceMapper.updateService(record);
        //服务变更后，修改老人分配
        Elderly elderly=new Elderly();
        elderly.setfId(record.getfElderlyId());
        elderly.setfServiceStaffId(record.getfOldServiceStaffId());
        int i =elderlyService.update(elderly);
        return  i;
    };
}
